if (!jsx3.lang.Class.forName("tibco.admin.enterpriseAssets.machines.addSrch.AddParams")) {
    /**
     **/
    jsx3.Class.defineClass(
            "tibco.admin.enterpriseAssets.machines.addSrch.AddParams",
            jsx3.lang.Object,
            null,
            function(addsearchparameters) {

                addsearchparameters.doValidateSearchName = function(button) {
                    var textbox = button.getAncestorOfType(jsx3.gui.Dialog).getDescendantOfName("txtName_21F");
                    if (tibco.admin.util.Validation.doValidateNotEmpty(textbox, null, textbox.getValue())) {
                        var cacheDoc = tibco.admin.Main.getServer().getCache().getDocument("searchParametersCache_21C");
                        if (cacheDoc.selectSingleNode("//record[@name='" + textbox.getValue().trim() + "']")) {
                            textbox.setTip(tibco.admin.Main.getServer().getDynamicProperty("@@NewSearchExists", textbox.getValue()))
                            textbox.setBackgroundColor("yellow", true);
                            return false;
                        } else {
                            textbox.setTip("");
                            textbox.setBackgroundColor("#FFFFFF", true);
                            return true;
                        }
                    }
                    return false;
                }
                /**
                 * Change selection
                 */
                addsearchparameters.onChangeSelectionType = function () {
                    var sel = tibco.admin.Main.getServer().getJSXByName("selType_21F");
                    var type = sel.getValue();

                    var bodyPane = tibco.admin.Main.getServer().getJSXByName("paneJmxSocketOptions_21F");
                    bodyPane.removeChildren();
                    // no need to load the associated dynamic properties file

                    if (type != null) {
                        if (type == 0) {
                            // load JMX
                            bodyPane.load("tibco/admin/enterpriseAssets/machines/addSrch/ui/resourcesAddSearchParameters4Jmx.xml");
                        }
                        else if (type == 1) {
                            // load Socket
                            bodyPane.load("tibco/admin/enterpriseAssets/machines/addSrch/ui/resourcesAddSearchParameters4Socket.xml");
                        }
                    }
                }


                addsearchparameters.closeDiscoveryConfigurationBlock = function() {
                    tibco.admin.Main.getServer().getJSXByName("blkWindowShade21G").scrollWindowVertical();
                }

                addsearchparameters.calladdJMXDiscoveryConfiguration = function(button) {
                    if (addsearchparameters.doValidateSearchName(button)) {
                        var objService = tibco.admin.Main.loadService("tibco.admin",
                                "tibco/admin/enterpriseAssets/machines/addSrch/rules/addJMXDiscoveryConfigurationRules.xml",
                                "addJMXDiscoveryConfiguration",
                                "add JMX discovery configuration");
                        objService.setEndpointURL(tibco.admin.util.ServiceHelper.getManagementDaemonEndpointURL())
                        objService.subscribe(jsx3.net.Service.ON_SUCCESS, addsearchparameters.onaddJMXDiscoveryConfigurationSuccess);
                        objService.doCall();
                    }
                };

                addsearchparameters.onaddJMXDiscoveryConfigurationSuccess = function(objEvent) {
                    addsearchparameters.refreshSearchParametersList();
                };


                addsearchparameters.calladdSocketDiscoveryConfiguration = function(button) {
                    if (addsearchparameters.doValidateSearchName(button)) {
                        var objService = tibco.admin.Main.loadService("tibco.admin",
                                "tibco/admin/enterpriseAssets/machines/addSrch/rules/addSocketDiscoveryConfigurationRules.xml",
                                "addSocketDiscoveryConfiguration",
                                "add socket discovery Configuration");
                        objService.setEndpointURL(tibco.admin.util.ServiceHelper.getManagementDaemonEndpointURL())
                        objService.subscribe(jsx3.net.Service.ON_SUCCESS, addsearchparameters.onaddSocketDiscoveryConfigurationSuccess);
                        objService.subscribe(jsx3.net.Service.ON_ERROR, addsearchparameters.onaddSocketDiscoveryConfigurationError);
                        objService.subscribe(jsx3.net.Service.ON_INVALID, addsearchparameters.onaddSocketDiscoveryConfigurationInvalid);
                        objService.doCall();
                    }
                };

                addsearchparameters.onaddSocketDiscoveryConfigurationSuccess = function(objEvent) {
                    //tibco.admin.util.PendingOperationsHandler.removeOperation(objEvent.target.opId);
                    tibco.admin.util.ServiceHelper.printInboundOutboundDocument(objEvent);
                    //if (!tibco.admin.util.ServiceHelper.logErrors("addSocketDiscoveryResponseCache_21A", "addSearchParameters", "addJMXDiscoveryConfiguration")) {
                    tibco.admin.util.Log.SERVICE.trace("The service call was successful.\nTimeout: " + objEvent.target.timeout + "\noperationHandler: " + objEvent.target.operationHandler);
                    addsearchparameters.refreshSearchParametersList();
                    // }

                };

                addsearchparameters.onaddSocketDiscoveryConfigurationError = function(objEvent) {
                    //tibco.admin.util.PendingOperationsHandler.removeOperation(objEvent.target.opId);
                    var myStatus = objEvent.target.getRequest().getStatus();
                    tibco.admin.util.Log.SERVICE.error("The service call failed. The HTTP Status code is: " + myStatus);
                    tibco.admin.util.ServiceHelper.printInboundOutboundDocument(objEvent);
                    //tibco.admin.util.ServiceHelper.logErrors("addSocketDiscoveryResponseCache_21A", "addSearchParameters", "addJMXDiscoveryConfiguration", objEvent);
                    tibco.admin.Main.cleareCacheById("addSocketDiscoveryResponseCache_21A")
                };

                addsearchparameters.onaddSocketDiscoveryConfigurationInvalid = function(objEvent) {
                    //tibco.admin.util.PendingOperationsHandler.removeOperation(objEvent.target.opId);
                    tibco.admin.util.ServiceHelper.logInvalid(objEvent, "addSearchParameters", "addSocketDiscoveryConfiguration");
                    tibco.admin.util.Log.SERVICE.error("The following message node just failed validation:\n\n" + objEvent.message);
                    tibco.admin.util.ServiceHelper.printInboundOutboundDocument(objEvent);
                };

                addsearchparameters.checkSaveEnable = function() {
                    var block = tibco.admin.Main.getServer().getJSXByName("blkAddSearchParamsPane_21F");
                    var sel = block.getDescendantOfName("selType_21F");
                    var type = sel.getValue();
                    if (type == 0) {
                        // load JMX
                        var saveButton = block.getDescendantOfName("btnAddSearchParam4JMX_21A");
                    }
                    else if (type == 1) {
                        // load Socket
                        var saveButton = block.getDescendantOfName("btnAddSearchParam4Socket_21A");
                    }
                    saveButton.setEnabled(jsx3.gui.Form.STATEDISABLED, true);
                    var nameVal = block.getDescendantOfName("txtName_21F").getValue();
                    var netInt = block.getDescendantOfName("txtNetworkInterface_21F").getValue();
                    var enable = tibco.admin.util.Validation.doValidateNotEmpty(block.getDescendantOfName("txtName_21F"),nameVal);
                    if(netInt && (netInt.length != tibco.admin.util.Validation.trimAll(netInt).length)) {
                        enable = false;
                        block.getDescendantOfName("txtNetworkInterface_21F").setBackgroundColor("yellow", true).setTip("Network Interface may not have leading or trailing spaces");
                    }
                    else {
                        block.getDescendantOfName("txtNetworkInterface_21F").setBackgroundColor("white", true).setTip("");
                    }
                    var hostVal = null;
                    var portVal = null;
                    if (type == 0) {
                        hostVal = block.getDescendantOfName("txtIPValue_21A").getValue();
                        portVal = block.getDescendantOfName("txtJmxPortnameValue_21A").getValue();
                        udpVal = block.getDescendantOfName("txtUdpPortValue_21A").getValue();
                        ipVal = block.getDescendantOfName("txtHostnameValue_21A").getValue();
                        enable = tibco.admin.util.Validation.doValidateNotEmptyNoWhSpace(block.getDescendantOfName("txtIPValue_21A"), hostVal) && enable;
                        enable = tibco.admin.util.Validation.doValidateIPAddresses(block.getDescendantOfName("txtHostnameValue_21A"), ipVal) && enable;
                        enable = tibco.admin.util.Validation.doValidatePort(block.getDescendantOfName("txtJmxPortnameValue_21A"), portVal) && enable;
                        enable = tibco.admin.util.Validation.doValidatePort(block.getDescendantOfName("txtUdpPortValue_21A"), udpVal) && enable;

                    }
                    else {
                        hostVal = block.getDescendantOfName("txtInputMulticastAddress_21A").getValue();
                        portVal = block.getDescendantOfName("txtSocketPort_21A").getValue();
                        enable = tibco.admin.util.Validation.doValidateIPAddresses(block.getDescendantOfName("txtInputMulticastAddress_21A"), hostVal) && enable;
                        enable = tibco.admin.util.Validation.doValidatePort(block.getDescendantOfName("txtSocketPort_21A"), portVal) && enable;
                    }
                    saveButton.setEnabled(enable ? jsx3.gui.Form.STATEENABLED : jsx3.gui.Form.STATEDISABLED, true);
                };

                addsearchparameters.refreshSearchParametersList = function() {
                    addsearchparameters.resetPanelValuesToDefaults();
                    addsearchparameters.closeDiscoveryConfigurationBlock();
                    var msg = new Object();
                    msg.subject = tibco.admin.enterpriseAssets.machines.search.EventID.SEARCH_PARAM_ADDED;
                    tibco.admin.PubSub.publish(msg);
                }

                addsearchparameters.resetPanelValuesToDefaults = function() {
                    // check the dropdown to know which panel is currently loaded
                    var topPane = tibco.admin.Main.getServer().getJSXByName("blkAddSearchParamsPane_21F");
                    var sel = topPane.getDescendantOfName("selType_21F");
                    var type = sel.getValue();
                    // reset the panel values
                    var subPane = topPane.getDescendantOfName("paneJmxSocketOptions_21F");
                    if (type != null) {
                        if (type == 0) {
                            // reset JMX values
                            subPane.getDescendantOfName("txtIPValue_21A").setValue("");
                            subPane.getDescendantOfName("txtJmxPortnameValue_21A").setValue("");
                            subPane.getDescendantOfName("txtHostnameValue_21A").setValue("239.100.106.107");
                            subPane.getDescendantOfName("txtUdpPortValue_21A").setValue("1965");
                        }
                        else if (type == 1) {
                            // reset Socket values
                            subPane.getDescendantOfName("txtInputMulticastAddress_21A").setValue("239.100.106.107");
                            subPane.getDescendantOfName("txtSocketPort_21A").setValue("1965");
                        }
                    }

                    topPane.getDescendantOfName("txtName_21F").setValue("NewSearch");
                    topPane.getDescendantOfName("tareaDescription_21F").setValue("");

                    // reset the dropdown selection
                    sel.setValue(1);
                    type = sel.getValue();

                    // reset the panel itself to the default panel, if required
                    subPane.removeChildren();
                    // no need to load the associated dynamic properties file

                    if (type != null) {
                        if (type == 0) {
                            // load JMX
                            subPane.load("tibco/admin/enterpriseAssets/machines/addSrch/ui/resourcesAddSearchParameters4Jmx.xml");
                        }
                        else if (type == 1) {
                            // load Socket
                            subPane.load("tibco/admin/enterpriseAssets/machines/addSrch/ui/resourcesAddSearchParameters4Socket.xml");
                        }
                    }
                }

            })
}